layui.use(['jquery','table','layer'],function () {
    var $ = layui.jquery;
    var table = layui.table;
    var layer = layui.layer;

    selectBeforeUserShutDown("","",2);
    function selectBeforeUserShutDown(account,reason,type) {
        table.render({
            elem:"#root",
            url:"/jsBeforeShutDown/selectBeforeShutDownLog?account="+account+"&reason="+reason+"&type="+type,
            defaultToolbar: ['','',''],
            cellHeight:57,
            page:true,
            limit:10,
            limits:[10,15,20],
            size: 'lg',
            cols:[[
                {type:"checkbox",align:"center"},
                {type:"numbers",title:"序号",align:"center"},
                {field:"userId",title:"用户编号",align:"center"},
                {field:"account",title:"用户账号",align:"center"},
                {field:"startDate",title:"封停时间",align:"center"},
                {field:"endDate",title:"解封时间",align:"center"},
                {field:"reason",title:"封停原因",align:"center"},
                {field:"type",title:"用户类型",align:"center",templet:function (data) {
                        if(data.type=="2"){
                            return "前端用户";
                        }
                    }},
                {title:"操作",align:"center",templet:function (data) {
                        return "<div>"
                            +"<a href='javascript:chakan("+data.userId+");' style='color: #2F4056;margin-right: 10px;'>查看</a>"
                            +"</div>"
                    }}
            ]]
        })
    };

    //查看
    chakan = function chakan(userId) {
        $.ajax({
            type:"post",
            dataType:"json",
            data:{"userId":userId},
            url:"/beforeUser/selectJsBeforeUserById",
            success:function (data) {
               chakanLayer(data.data[0]);
            }
        });
    };
    function chakanLayer(data){
        var obj;
        layer.open({
            type:2,
            shode:0,
            maxmin:true,
            title:"查看用户信息",
            content:"/user/before-user-see.html",
            area:['1000px','690px'],
            btn:["关闭"],
            yes:function (index) {
                layer.close(index);
            },success:function (layero,index) {
                obj = layero.find('iframe').contents();
                obj.find("#avatarUrl").attr("src",'http://'+data.avatarUrl);
                obj.find("#account").val(data.account);
                obj.find("#nickname").val(data.nickname);
                obj.find("#userCode").val(data.userCode);
                obj.find("#fullName").val(data.fullName);
                obj.find("#sex").val(data.sex);
                obj.find("#idCard").val(data.idCard);
                obj.find("#phone").val(data.phone);
                obj.find("#email").val(data.email);
                obj.find("#profession").val(data.profession);
                obj.find("#integration").val(data.integration);
                obj.find("#consumption").val(data.consumption);
                obj.find("#studyDate").val(data.studyDate);
                obj.find("#entranceDate").val(data.entranceDate);
                obj.find("#graduationDate").val(data.graduationDate);
                obj.find("#createDate").val(data.createDate);
                obj.find("#freestyle").val(data.freestyle);
            }
        })
    };
    
    //搜素
    $("#sousuo").click(function () {
        var account = $("#account").val();
        var reason = $("#reason").val();
        selectBeforeUserShutDown(account,reason,2);
    })
    //重置
    $("#reset").click(function () {
        $("#account").val("");
        $("#reason").val("");
        selectBeforeUserShutDown("","",2);
    });

    //刷新
    $('#shuaxin').click(function () {
        location.reload();
    });

    //返回
    $("#goBack").click(function (s) {
        parent.$('#Jump').val('首页');
        parent.getQuick();
        return;
    });
})